Skip to content

fix(desktop): relay Brain analytics with Desktop identity - #7356

Merged
Nixieboluo merged 2 commits into
labring:mainfrom
zjy365:codex/relay-brain-analytics
Oct 12, 2026
Merged

Nixieboluo merged 2 commits into
labring:mainfrom
zjy365:codex/relay-brain-analytics

Conversation

@zjy365

@zjy365 zjy365 commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

After Desktop emits module_open, embedded Brain events use a different analytics context and cannot read Desktop's persisted UUID. Deployment creation can be blocked by GTM's missing-identity rule, and the current GTM whitelist omits onboarding/cancellation events.

Expose an optional analytics capability through the existing host-config API and accept Brain events through the existing SDK event bus. Event callbacks receive browser-provided source/origin metadata; the relay accepts only the running Brain iframe and its installed origin. GTM-covered events enter the parent dataLayer once, inheriting the canonical Desktop UUID and attribution. Events absent from the GTM whitelist use the parent Rybbit SDK once, identifying with that same UUID and respecting the primitive/2KB property contract. Direct delivery waits for asynchronous SDK loading; event fields are allowlisted.

Companion Brain PR: labring/brain#359. Deploy this Desktop change first for immediate continuity. Either PR remains independently mergeable; Brain negotiates capability and keeps its previous transport on older Desktop deployments. Existing website token-login tracking from main is retained.

Validation:

  • 19 focused tests passed: pnpm test:ci src/__tests__/unit/utils/brain-analytics.test.ts src/__tests__/unit/utils/brain-analytics-sdk.test.ts src/__tests__/unit/utils/gtm.test.ts src/__tests__/unit/utils/marketing-attribution.test.ts from frontend/desktop.
  • pnpm exec tsc --noEmit --incremental false from frontend/desktop.
  • pnpm build from frontend/packages/client-sdk.
  • Coverage includes real SDK sender propagation/acknowledgement, iframe/origin rejection, one-time GTM/Rybbit dispatch, UUID identity, late script loading, byte limits, and exclusion of credentials/feedback text.

@zjy365 zjy365 added this to the v5.2 milestone Oct 12, 2026

@Nixieboluo Nixieboluo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Nixieboluo
Nixieboluo merged commit 74bf2df into labring:main Oct 12, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants